<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理后台 - 有偿知识问答系统</title>
    <link rel="stylesheet" href="/knowledge-qa/static/css/style.css">
    <link rel="stylesheet" href="/knowledge-qa/static/css/modern_style.css">
    <style>
        body {
            margin: 0;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background-color: #f0f2f5;
        }
        .container {
            display: flex;
            height: 100vh;
        }
        .sidebar {
            width: 200px;
            background-color: #001529;
            color: white;
            padding: 20px 0;
            flex-shrink: 0;
        }
        .sidebar-header {
            padding: 0 20px 20px;
            font-size: 18px;
            font-weight: bold;
            border-bottom: 1px solid rgba(255,255,255,0.1);
        }
        .menu-item {
            padding: 12px 20px;
            cursor: pointer;
            transition: all 0.3s;
            color: rgba(255,255,255,0.65);
        }
        .menu-item:hover {
            background-color: rgba(255,255,255,0.08);
            color: white;
        }
        .menu-item.active {
            background-color: #1890ff;
            color: white;
        }
        .content {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
        }
        .header {
            background-color: white;
            padding: 10px 20px;
            border-radius: 4px;
            margin-bottom: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .header-title {
            font-size: 20px;
            font-weight: bold;
            color: #333;
        }
        .header-info {
            display: flex;
            align-items: center;
        }
        .welcome-text {
            margin-right: 20px;
            color: #666;
        }
        .btn {
            padding: 6px 16px;
            border-radius: 4px;
            cursor: pointer;
            border: none;
            font-size: 14px;
            transition: all 0.3s;
        }
        .btn-primary {
            background-color: #1890ff;
            color: white;
        }
        .btn-primary:hover {
            background-color: #40a9ff;
        }
        .btn-danger {
            background-color: #ff4d4f;
            color: white;
        }
        .btn-danger:hover {
            background-color: #ff7875;
        }
        .main-content {
            background-color: white;
            padding: 20px;
            border-radius: 4px;
            min-height: 400px;
        }
        .stats-container {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 20px;
            margin-bottom: 20px;
        }
        .stat-card {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        .stat-title {
            font-size: 14px;
            color: #666;
            margin-bottom: 10px;
        }
        .stat-value {
            font-size: 24px;
            font-weight: bold;
            color: #333;
        }
        .stat-change {
            font-size: 12px;
            margin-top: 5px;
        }
        .stat-change.positive {
            color: #52c41a;
        }
        .stat-change.negative {
            color: #ff4d4f;
        }
        .recent-activities {
            background-color: white;
            padding: 20px;
            border-radius: 4px;
        }
        .section-title {
            font-size: 18px;
            font-weight: bold;
            color: #333;
            margin-bottom: 15px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #f0f0f0;
        }
        th {
            background-color: #fafafa;
            font-weight: bold;
            color: #666;
        }
        tr:hover {
            background-color: #fafafa;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 侧边栏 -->
        <div class="sidebar">
            <div class="sidebar-header">管理后台</div>
            <div class="menu-item active" onclick="loadAdminContent('dashboard')">
                首页概览
            </div>
            <div class="menu-item" onclick="loadAdminContent('users')">
                用户管理
            </div>
            <div class="menu-item" onclick="loadAdminContent('questions')">
                问题管理
            </div>
            <div class="menu-item" onclick="loadAdminContent('answers')">
                回答管理
            </div>
            <div class="menu-item" onclick="loadAdminContent('transactions')">
                金币交易
            </div>
        </div>
        
        <!-- 主内容区域 -->
        <div class="content">
            <div class="header">
                <div class="header-title">有偿知识问答系统管理后台</div>
                <div class="header-info">
                    <span class="welcome-text" id="welcomeText">欢迎，管理员</span>
                    <button class="btn btn-danger" onclick="adminLogout()">退出登录</button>
                </div>
            </div>
            
            <div class="main-content" id="adminContent">
                <!-- 首页概览内容 -->
                <div id="dashboardContent">
                    <h2 class="section-title">系统概览</h2>
                    
                    <div class="stats-container">
                        <div class="stat-card">
                            <div class="stat-title">总用户数</div>
                            <div class="stat-value" id="totalUsers">0</div>
                            <div class="stat-change positive">+5.2% 较上周</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-title">总问题数</div>
                            <div class="stat-value" id="totalQuestions">0</div>
                            <div class="stat-change positive">+3.8% 较上周</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-title">总回答数</div>
                            <div class="stat-value" id="totalAnswers">0</div>
                            <div class="stat-change positive">+8.4% 较上周</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-title">总交易金额</div>
                            <div class="stat-value" id="totalCoins">0</div>
                            <div class="stat-change positive">+12.5% 较上周</div>
                        </div>
                    </div>
                    
                    <div class="recent-activities">
                        <h3 class="section-title">悬赏排行</h3>
                        <table>
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>用户</th>
                                    <th>活动类型</th>
                                    <th>时间</th>
                                    <th>详情</th>
                                </tr>
                            </thead>
                            <tbody id="recentActivitiesTable">
                                <!-- 悬赏排行将通过JavaScript动态加载 -->
                                <tr>
                                    <td colspan="5" style="text-align: center; color: #999;">加载中...</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 管理员相关JavaScript -->
    <script src="/knowledge-qa/static/js/admin.js"></script>
</body>
</html>